home *** CD-ROM | disk | FTP | other *** search
/ Painter Bear's Language Bridge — Italian / Bridge_ponte_itialian.iso / pc / helpers / open.dxr / 00015_word find.ls < prev    next >
Encoding:
Text File  |  2001-02-22  |  5.3 KB  |  158 lines

  1. on prepWdFind
  2.   global gFindTitle, gFindInstr, gLangDirect, gLangSelect
  3.   sound stop 1
  4.   go("find")
  5.   doMusicBtn()
  6.   set the editable of member "wordFind" to 1
  7.   if gLangDirect = 1 then
  8.     set the memberNum of sprite gFindTitle to the number of member "e findTitle"
  9.     set the memberNum of sprite gFindInstr to the number of member "e findInstr"
  10.   else
  11.     set the memberNum of sprite gFindTitle to the number of member (gLangSelect & " findTitle")
  12.     set the memberNum of sprite gFindInstr to the number of member (gLangSelect & " findInstr")
  13.   end if
  14. end
  15.  
  16. on findWord
  17.   global gLangDirect, gLangName, gFindMouth, gLangSelect
  18.   cursor(4)
  19.   put EMPTY into field "possWords"
  20.   put EMPTY into field "wordFound"
  21.   set the editable of member "wordFind" to 0
  22.   set findText to field "wordFind"
  23.   if findText <> EMPTY then
  24.     set gDB to new(xtra("v12dbe"), the moviePath & "lang.v12", "readOnly", EMPTY)
  25.     set gDBTable to new(xtra("v12table"), mGetRef(gDB), "language")
  26.     if gLangDirect = 1 then
  27.       set searchField to "myEnglish"
  28.     else
  29.       set searchField to "my" & gLangName
  30.     end if
  31.     mSetCriteria(gDBTable, searchField, "wordStarts", findText)
  32.     mSetCriteria(gDBTable, "or", searchField, "starts", findText)
  33.     mOrderBy(gDBTable, searchField, "ascending")
  34.     mSelect(gDBTable)
  35.     set selSize to mSelectCount(gDBTable)
  36.     if selSize = 0 then
  37.       if gLangDirect = 1 then
  38.         put "Sorry, no results found" into field "possWords"
  39.       else
  40.         case gLangSelect of
  41.           "g":
  42.             put "Es konnten leider keine Ergebnisse gefunden werden." into field "possWords"
  43.           "f":
  44.             put "D√©sol√©, aucun r√©sultat." into field "possWords"
  45.           "s":
  46.             put "Lo siento, no hay resultados grabados." into field "possWords"
  47.           "i":
  48.             put "Mi dispiace, non si trova nessun risultato." into field "possWords"
  49.         end case
  50.       end if
  51.       set the memberNum of sprite gFindMouth to the number of member "findSnd gray"
  52.     else
  53.       repeat with X = 1 to selSize
  54.         put mGetField(gDBTable, searchField) & RETURN after field "possWords"
  55.         mGoNext(gDBTable)
  56.       end repeat
  57.     end if
  58.     set gDBTable to 0
  59.     set gDB to 0
  60.     if selSize <> 0 then
  61.       set the scrollTop of member "possWords" to 1
  62.       hilite line 1 of field "possWords"
  63.       translateWord(line 1 of field "possWords")
  64.     end if
  65.   else
  66.     set the memberNum of sprite gFindMouth to the number of member "findSnd gray"
  67.   end if
  68.   set the editable of member "wordFind" to 1
  69.   cursor(-1)
  70. end
  71.  
  72. on translateWord whichWord
  73.   global gLangName, gLangDirect, gFindSnd, gLangSelect, gSndPath, gFileDelimiter, gCat, gFindMouth
  74.   cursor(4)
  75.   set gDB to new(xtra("v12dbe"), the moviePath & "lang.v12", "readOnly", EMPTY)
  76.   set gDBTable to new(xtra("v12table"), mGetRef(gDB), "language")
  77.   if gLangDirect = 1 then
  78.     set searchField to "myEnglish"
  79.     set takeField to "my" & gLangName
  80.     set sndPth to gLangSelect
  81.   else
  82.     set searchField to "my" & gLangName
  83.     set takeField to "myEnglish"
  84.     set sndPth to "e"
  85.   end if
  86.   mSetCriteria(gDBTable, searchField, "=", whichWord)
  87.   mOrderBy(gDBTable, searchField, "ascending")
  88.   mSelect(gDBTable)
  89.   put mGetField(gDBTable, takeField) into field "wordFound"
  90.   set gFindSnd to mGetField(gDBTable, "myCodeName")
  91.   set cat to chars(gFindSnd, 1, 4)
  92.   set gFindSnd to gSndPath & sndPth & gFileDelimiter & cat & gFileDelimiter & gFindSnd & ".aif"
  93.   set gDBTable to 0
  94.   set gDB to 0
  95.   set the memberNum of sprite gFindMouth to the number of member "findSnd up"
  96.   cursor(-1)
  97. end
  98.  
  99. on createDatabase
  100.   global gFileDelimiter, gDB
  101.   cursor(4)
  102.   set whichPath to the moviePath
  103.   set gDB to new(xtra("v12dbe"), whichPath & "lang.v12", "create", EMPTY)
  104.   if V12Status() then
  105.     alert("error code" && V12Error())
  106.   end if
  107.   mEditDBStructure(gDB)
  108.   mReadDBStructure(gDB, "Literal", field "langTemplate")
  109.   if V12Status() then
  110.     alert("error code" && V12Error())
  111.   end if
  112.   mBuild(gDB)
  113.   if V12Status() then
  114.     alert("error code" && V12Error())
  115.   end if
  116.   put mDumpStructure(gDB)
  117.   set gDB to 0
  118.   cursor(-1)
  119. end
  120.  
  121. on loadDatabase
  122.   cursor(4)
  123.   set gDB to new(xtra("v12dbe"), the moviePath & "lang.v12", "readWrite", EMPTY)
  124.   set gDBTable to new(xtra("v12table"), mGetRef(gDB), "language")
  125.   set the itemDelimiter to "*"
  126.   repeat with X = 1 to the number of lines in field "e vocab"
  127.     set aLine to line X of field "e vocab"
  128.     set aNum to item 1 of aLine
  129.     set aEngWord to item 2 of aLine
  130.     if item 1 of line X of field "s vocab" = aNum then
  131.       set aFWord to item 3 of line X of field "f vocab"
  132.       set aIWord to item 3 of line X of field "I vocab"
  133.       set aSWord to item 3 of line X of field "s vocab"
  134.       set aGWord to item 3 of line X of field "g vocab"
  135.       mAddRecord(gDBTable)
  136.       mSetField(gDBTable, "myCodeName", aNum)
  137.       mSetField(gDBTable, "myEnglish", aEngWord)
  138.       mSetField(gDBTable, "myFrench", aFWord)
  139.       mSetField(gDBTable, "mySpanish", aSWord)
  140.       mSetField(gDBTable, "myGerman", aGWord)
  141.       mSetField(gDBTable, "myItalian", aIWord)
  142.       mUpdateRecord(gDBTable)
  143.     else
  144.       alert("Something's Wrong with the numbers!")
  145.     end if
  146.     if V12Status() then
  147.       alert("error code" && V12Error())
  148.     end if
  149.   end repeat
  150.   if V12Status() then
  151.     alert("error code" && V12Error())
  152.   end if
  153.   set gDBTable to 0
  154.   set gDB to 0
  155.   set the itemDelimiter to ","
  156.   cursor(-1)
  157. end
  158.